home *** CD-ROM | disk | FTP | other *** search
- Path: news.compuserve.com!newsmaster
- From: 71024.1713@compuserve.com
- Newsgroups: comp.lang.c++
- Subject: Re: for loop question
- Date: Wed, 31 Jan 1996 22:39:54 GMT
- Organization: CompuServe Incorporated
- Message-ID: <4eor22$r83@dub-news-svc-5.compuserve.com>
- References: <4emqf8$470@opal.southwind.net>
- NNTP-Posting-Host: hd83-002.compuserve.com
- X-Newsreader: Forte Free Agent 1.0.82
-
- kurtg@southwind.net (Kurt Graber) wrote:
-
- >I am currently learning c++ so maybe you gurus can answer this
- >also I am using borland turbo c++ 3.0
- >I can't get the following code to give me any output.
-
- >#include <iostream.h>
-
- >void main (void)
- >{
- > int a;
- > for(a = 0;a == 10;a++)
- > {
- > cout << "anything";
- > }
- >}
-
- >///If I change the loop to for(a=0;a<=10;a++)
- > the program will work fine.
- > why?????????
- > thanks
- > kurt
-
- Kurt,
- The reason the first example doesn't work is that in a for loop
- the second part, a==10 in this case, has to be true or the for loop
- ends. So in other words a for loop works as follows, while the second
- part is true, do the third and loop.
-
- John
-
-
-